var tableToExcel =
		(function() {
			var uri = 'data:application/vnd.ms-excel;base64,', template =
					'<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{Worksheet}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--></head><body><table>{table}</table></body></html>', base64 =
					function(s) {
						return window.btoa(unescape(encodeURIComponent(s)))
					}, format = function(s, c) {
				return s.replace(/{(\w+)}/g, function(m, p) {
					return c[p];
				})
			}
			return function(table, name) {
				console.log(table);
				console.log(name);
				if (!table.nodeType)
					table = document.getElementById("exportReport")
				var ctx = {
					worksheet : name || 'Worksheet',
					table : table.innerHTML
				}
				window.location.href = uri + base64(format(template, ctx))
			}
		})()


var now = new Date();
var day = ("0" + now.getDate()).slice(-2);
var temp = now.getDate() - 1;
var old = ("0" + temp).slice(-2);

var month = ("0" + (now.getMonth() + 1)).slice(-2);
var today = (day) + "-" + (month) + "-" + now.getFullYear();
var yesterday = (old) + "-" + (month) + "-" + now.getFullYear();
var checkedkey = [];
var checkedvalue = [];
var deletedataArr = {};
var updatedataArr = {};

var saleryTypeVal ="";
var rtoDocumentval ="";
var modeOfPaymentval ="";

var previousText = "";
var tempthis= "";
var clickId ="";
var currentRowId = "";
var uniqueId ="";
$(document).ready(function(){
	window.alert = function() {};

	alert = function() {};
	
	
	
	if(sessionStorage.getItem("username") ==null){
		 window.location = "satvik_login.html";
	}
	
	$( "#startDate" ).datepicker({dateFormat : 'dd-mm-yy'});
	$( "#endDate" ).datepicker({dateFormat : 'dd-mm-yy'});
	
		
	$( "#startDate" ).val(yesterday);
	$( "#endDate" ).val(today);
	
	$("#search").click();
	
});
$(document).on('click', '#search', function(e){
	
	
	$.ajax({
		 url: "getSearchData?r="+Math.random(),
	     type: "Get",
	     data: {
	    	 "startDate" :$("#startDate").val(),
	    	 "endDate"   :$("#endDate").val(),
	    	 "aplicantName"   :$("#aplicantName").val(),
	    	 "lastName"   :$("#lastName").val()
	    },
	     success: function(data){
	    	 console.log("reportData",data);
	    	 data = $.trim(data);
	    	 if(data !="nodataFound"){
	    		 /*data = $.parseJSON(data);*/
	    		 console.log("reportData",data);
	    		 deletedataArr = {};
	    		 checkedkey = [];
	    		 fillData(data);
		    	/// fillDataToPrintTable(data);
	    	 }
	    	 else{
	    		 $("#reportTable").hide();
	    		 $("#nodataFound").show();
	    		 $("#detailDiv").empty();
	    	 }
	     },
	     error: function () {
	    	 console.log("here error");
	    	// sessionStorage.setItem("userlogin"+origCompId,"");
	     },async:false,
		
	});
	
});


$(document).on("change", "input:checkbox", function(e) {
	var valueofcheck = $(this).val();
	console.log("valueofcheck", valueofcheck);
	
	if ($(this).is(':checked')) {
		console.log($(this).closest("tr").attr("name"));
		checkedkey.push($(this).closest("tr").attr("id"));
		checkedvalue.push($(this).closest("tr").attr("name"));
		

	} else {
		console.log($(this).closest("tr").attr("name"));
		checkedkey.pop($(this).closest("tr").attr("id"));
		checkedvalue.pop($(this).attr("name"));
	}
	console.log(checkedvalue,"",checkedkey);
});
$(document).on("click", "#delete", function(e) {
	
	
	
	for (var i = 0; i < checkedvalue.length; i++) {
		deletedataArr["uniqueApplicantId" + i] = checkedvalue[i];
	}
	if(checkedvalue.length >0){
		$("#detailDiv").empty();
		$.ajax({
			 url: "FormDataController?r="+Math.random(),
		     type: "Get",
		     data: {
		    	 "flag"		 :"deletData",
		    	 "dataToDelete" :JSON.stringify(deletedataArr),
		    	 
		    },
		     success: function(data){
		    	 data = $.trim(data);
		    	 if(data =="done"){
		    		 $("#detailDiv").empty();
		    		 $.each(checkedkey, function(key, value) {
		    				$("#reportTable #" + value).remove();
		    				
		    				
		    				console.log(key, value);
		    			});
		    		 $("#detailDiv").append("<h3>Data Deleted Successfully.........</h>");
		    	 }else{
		    		 $("#detailDiv").empty();
		    			$("#detailDiv").append("<h3>Sorry some error occured while deleting data please try again</h>");
		    	 }
		     },
		     error: function () {
		    	 console.log("here error");
		    	// sessionStorage.setItem("userlogin"+origCompId,"");
		     },async:false,
			
		});
	}else{
		$("#detailDiv").empty();
		$("#detailDiv").append("<h3>Please select atleast one row to delete</h>");
	}
	
	
	
});

$(document).on("click", ".tdTextEdit", function(e) {
	
	if(previousText !=""){
		$(tempthis).empty();
		$(tempthis).append(previousText);
		$(tempthis).addClass("tdTextEdit");
	}
	
	
	currentRowId = $(this).closest("tr").attr("id");
	uniqueId = $(this).closest("tr").attr("name");
	clickId = $(this).attr("id");
	
	alert("uniqueId"+uniqueId+"......"+clickId);
	
	if(clickId !="deleteCheckBox"){
		previousText = $(this).text();
		
		currentText = $(this).text();
		
		
		
		//alert(previousText);
		if(clickId == "dateOfBirth" || clickId == "VahicalDate" || clickId == "date_of_emi" || clickId == "FinalDate" ){
			$(this).empty();
			$(this).append("<input type='text' value='"+currentText+"' id='"+clickId+"1' /><br>" +
					"<a href='#'id='updateClick'>Update</a>&nbsp;&nbsp;&nbsp;<a href='#'id='cancelClick'>Cancel</a>");
			$(this).removeClass("tdTextEdit");
			$("#"+clickId+"1").datepicker({dateFormat : 'dd-mm-yy'});
			console.log("in if");
		}else if(clickId =="Type_Salary"){
			$(this).empty();
			var temp = $(this);
			console.log("saleryTypeVal",saleryTypeVal);
			
			var tempCode = "";
			$.each(saleryTypeVal,function(key,value){
				console.log("vale............",value);
				
				key = $.trim(key);
				currentRowId = $.trim(currentRowId);
				
				if(key == currentRowId){
					var i = 0;
					$.each(value,function(key,value){
					
						console.log(key,"hi",value);
						
						if(i == 5){
							tempCode = "<br>";
						}else{
							tempCode="";
						}
						var tempName = key.replace("_"," ");
						$(temp).append("&nbsp;"+tempName+" : <input type='checkBox' name="+key+" class='typeSalery'/>"+tempCode	+"");
						$("input:checkBox[name="+key+"]").prop("checked",value);
						i++;
					});
				}
			});
			$(this).append("<a href='#'id='updateClick'>Update</a>&nbsp;&nbsp;&nbsp;<a href='#'id='cancelClick'>Cancel</a>");
			$(this).removeClass("tdTextEdit");
		}
		else if(clickId =="DOCUMENT_RTO_PASSING"){
			$(this).empty();
			var temp = $(this);
			console.log("rtoDocumentval",rtoDocumentval);
			
			var tempCode = "";
			$.each(rtoDocumentval,function(key,value){
				
				key = $.trim(key);
				currentRowId = $.trim(currentRowId);
				
				if(key == currentRowId){
					var i = 0;
					$.each(value,function(key,value){
						
						console.log(key,"hi",value);
						
						if(i == 5){
							tempCode = "<br>";
						}else{
							tempCode="";
						}
						var tempName = key.replace("_"," ");
						$(temp).append("&nbsp;"+tempName+" : <input type='checkBox' name="+key+" class='rtoDocument'/>"+tempCode	+"");
						$("input:checkBox[name="+key+"]").prop("checked",value);
						i++;
					});
				}
				
			});
			$(this).append("<a href='#'id='updateClick'>Update</a>&nbsp;&nbsp;&nbsp;<a href='#'id='cancelClick'>Cancel</a>");
			$(this).removeClass("tdTextEdit");
		}
		else if(clickId =="Mode_Of_Payment"){
			$(this).empty();
			var temp = $(this);
			console.log("Mode_Of_Payment",modeOfPaymentval);
			
			var tempCode = "";
			$.each(modeOfPaymentval,function(key,value){
				
				key = $.trim(key);
				currentRowId = $.trim(currentRowId);
				
				if(key == currentRowId){
					var i = 0;
					$.each(value,function(key,value){
						
						console.log(key,"hi",value);
						
						if(i == 5){
							tempCode = "<br>";
						}else{
							tempCode="";
						}
						var tempName = key.replace("_"," ");
						$(temp).append("&nbsp;"+tempName+" : <input type='checkBox' name="+key+" class='modeOfpayment'/>"+tempCode	+"");
						$("input:checkBox[name="+key+"]").prop("checked",value);
						i++;
					});
				}
				
				
			});
			$(this).append("<a href='#'id='updateClick'>Update</a>&nbsp;&nbsp;&nbsp;<a href='#'id='cancelClick'>Cancel</a>");
			$(this).removeClass("tdTextEdit");
		}
		else{
			
			$(this).empty();
			$(this).append("<input type='text' value='"+currentText+"' id='"+clickId+"1' /><br>" +
					"<a href='#'id='updateClick'>Update</a>&nbsp;&nbsp;&nbsp;<a href='#'id='cancelClick'>Cancel</a>");
			$(this).removeClass("tdTextEdit");
			
		}
		tempthis = $(this);
	}
});
$(document).on("click", "#updateClick", function(e) {
	
	console.log(clickId);
	var temp = "";
	
	
	if(clickId =="Mode_Of_Payment"){
		updateVal = {};
		$(".modeOfpayment").each(function (e){
			console.log(clickId);
			var name = $(this).attr("name");
			if($(this).is(":checked")){
				updateVal[name] = true;
				
				
			}else{
				updateVal[name] = false;
			}
			
		});
		
		modeOfPaymentval[currentRowId] = updateVal;
		$.each(updateVal,function(key,value){
			if(value){
				if(temp !=""){
					temp =temp+","+key.replace("_"," ");
				}
				else{
					temp =key.replace("_"," ");
				}
			}
			
		});	
	}else if(clickId == "DOCUMENT_RTO_PASSING"){
		updateVal = {};
		$(".rtoDocument").each(function (e){
			
			var name = $(this).attr("name");
			if($(this).is(":checked")){
				updateVal[name] = true;
				
				
			}else{
				updateVal[name] = false;
			}
		});
		rtoDocumentval[currentRowId] = updateVal;
		$.each(updateVal,function(key,value){
			if(value){
				if(temp !=""){
					temp =temp+","+key.replace("_"," ");
				}
				else{
					temp =key.replace("_"," ");
				}
			}
			
		});	
		
	}else if( clickId == "Type_Salary"){
		updateVal = {};
		$(".typeSalery").each(function (e){
			console.log(clickId);
			var name = $(this).attr("name");
			if($(this).is(":checked")){
				updateVal[name] = true;
				
				
			}else{
				updateVal[name] = false;
			}
			
			
		});
		
		saleryTypeVal[currentRowId] = updateVal;
		
		$.each(updateVal,function(key,value){
			if(value){
				if(temp !=""){
					temp =temp+","+key.replace("_"," ");
				}
				else{
					temp =key.replace("_"," ");
				}
			}
			
		});	
		
	}else{
		updateVal = $("#"+clickId+"1").val();
		
		updateVal = $.trim(updateVal);
		previousText = $.trim(previousText);
		temp = updateVal;
	}
	
	
	
	alert(updateVal);
	/*if(updateVal.length >0){*/
		alert("here");
		updatedataArr['id'] = uniqueId;
		updatedataArr['colId'] = clickId;
		updatedataArr['colval'] = updateVal;
		
		
		
		console.log(updatedataArr);
		/*if(updateVal !=previousText){*/
			alert("here");
			$.ajax({
				 url: "FormDataController?r="+Math.random(),
			     type: "Get",
			     data: {
			    	 "flag"		 :"updateData",
			    	 "dataToUpdate" :JSON.stringify(updatedataArr),
			    	 
			    },
			     success: function(data){
			    	console.log("update Status"+data);
			    	
			    	data = $.trim(data);
			    	
			    	if(data =="done"){
			    		$(tempthis).empty();
						$(tempthis).append(temp);
					    $("#detailDiv").empty();
			    		$("#detailDiv").append("<h3>Data updated Successfully.........</h>");
						//alert(previousText+tempthis);
			    		$(tempthis).addClass("tdTextEdit");
						previousText = "";
			    	}
			     },
			     error: function () {
			    	 console.log("here error");
			    	
			     },async:false,
				
			});
		/*}else{
			$(tempthis).empty();
			$(tempthis).append(previousText);
			//alert(previousText+tempthis);
			$(tempthis).addClass("tdTextEdit");
		}
		
	}*/
	
	
	e.preventDefault(); 
	
	
});

$(document).on("click", "#cancelClick", function(e) {
	
	if(previousText !=""){
		
		$(tempthis).empty();
		$(tempthis).append(previousText);
		//alert(previousText+tempthis);
		$(tempthis).addClass("tdTextEdit");
	}
	//e.preventdefault();
	e.preventDefault(); 
});

$(document).on("click", "#eportToExcel", function(e) {
	
	tableToExcel('exportReport', 'W3C Example Table');
	e.preventDefault(); 
});
$(document).on("click", "#printForm", function(e) {
	for (var i = 0; i < checkedvalue.length; i++) {
		deletedataArr["uniqueApplicantId" + i] = checkedvalue[i];
		var url = "printForm.html?uniqueApplicantId="+deletedataArr["uniqueApplicantId" + i]; 
		window.open(url,"_blank");
		
	}
	
});

function fillData(dataArr){
	dataArr = $.parseJSON(dataArr);
	$("#detailDiv").empty();
	$("#reportTable").empty();
	$("#reportTable").append("<thead><tr><th>Delete</th><th>Application Name</th><th>Father/Husband Name</th><th>Date Of Birth</th><th>Gender</th>" +
			"<th>Marital Status</th><th>Current Job</th><th>Type Salary</th><th>Address</th><th>City</th><th>District</th><th>State</th>" +
			"<th>Pin Code</th><th>Phone No</th><th>Mobile No</th><th>Bank Name</th><th>Branch City</th><th>Account No</th><th>IFSC Code</th>" +
			"<th>C.I.No</th><th>Pan No</th><th>Nomine Name</th><th>Realtion</th><th>DOCUMENT RTO PASSING</th><th>Email Address</th><th>Booking Purchase Of Product</th>" +
			"<th>Show Room On Road Prise/Accessories</th><th>Chaque/DD No</th><th>Mode Of Payment</th><th>Bank</th><th>Amount</th>" +
			"<th>Date</th><th>Fainance By</th><th>Lone</th><th>Dealer/Showroom</th><th>Down Payment</th><th>Inteaset</th><th>EMI & Month</th>" +
			"<th>Date Of EMI</th><th>Sahakar A.I.LTD.D.P</th><th>Sub Cidy</th><th>Motor Vehicle No</th><th>Engin No</th><th>Chassis No</th>" +
			"<th>Color</th><th>Promotors Name</th><th>Id No</th><th>Cell No</th><th>Date</th></tr></thead>");
		var i = 1;

		rtoDocumentval = {}; 
		saleryTypeVal = {};
		modeOfPaymentval = {};
		console.log(dataArr);
		$.each(dataArr,function(key,value){
			
			
			
			rtoDocumentval ["row"+i] = value["DOCUMENT_RTO_PASSING"]; 
			saleryTypeVal["row"+i] = value["Type_Salary"];
			modeOfPaymentval["row"+i] = value["Mode_Of_Payment"];
			
			 
			
			
			$("#reportTable").append("<tr id=row"+i+" name="+value["id"]+"></tr>");
			
			$("#reportTable #row"+i).append("<td align='center'  class='noshow' id='deleteCheckBox'><input type='checkbox' ></td>");
			
			$("#reportTable #row"+i).append("<td id='applicant_name'>"+value["applicant_name"]+"</td>");
			$("#reportTable #row"+i).append("<td id='father_husband_name'>"+value["father_husband_name"]+"</td>");
			$("#reportTable #row"+i).append("<td id='dateOfBirth'>"+value["dateOfBirth"]+"</td>");
			$("#reportTable #row"+i).append("<td id='sex'>"+value["sex"]+"</td>");
			$("#reportTable #row"+i).append("<td id='MaritalStatus'>"+value["MaritalStatus"]+"</td>");
			$("#reportTable #row"+i).append("<td id='CurrentJob'>"+value["CurrentJob"]+"</td>");
			$("#reportTable #row"+i).append("<td id='Type_Salary'></td>");
			var temp = $.parseJSON(value["Type_Salary"]);
			
			$.each(temp,function(key,value){
				if(value){
					$("#reportTable #row"+i+" #Type_Salary").append(key.replace("_"," ")+", ");
				}
				
			});
			
			
			$("#reportTable #row"+i).append("<td id='address'>"+value["address"]+"</td>");
			$("#reportTable #row"+i).append("<td id='City'>"+value["City"]+"</td>");
			$("#reportTable #row"+i).append("<td id='District'>"+value["District"]+"</td>");
			$("#reportTable #row"+i).append("<td id='State'>"+value["State"]+"</td>");
			$("#reportTable #row"+i).append("<td id='Pin_Code'>"+value["Pin_Code"]+"</td>");
			$("#reportTable #row"+i).append("<td id='Phone_No'>"+value["Phone_No"]+"</td>");
			$("#reportTable #row"+i).append("<td id='mobileNo'>"+value["mobileNo"]+"</td>");
			$("#reportTable #row"+i).append("<td id='bank_name'>"+value["bank_name"]+"</td>");
			$("#reportTable #row"+i).append("<td id='branch_city'>"+value["branch_city"]+"</td>");
			$("#reportTable #row"+i).append("<td id='account_no'>"+value["account_no"]+"</td>");
			$("#reportTable #row"+i).append("<td id='IFSC_code'>"+value["IFSC_code"]+"</td>");
			$("#reportTable #row"+i).append("<td id='c_i_no'>"+value["c_i_no"]+"</td>");
			$("#reportTable #row"+i).append("<td id='pan_no'>"+value["pan_no"]+"</td>");
			$("#reportTable #row"+i).append("<td id='nomine_name'>"+value["nomine_name"]+"</td>");
			$("#reportTable #row"+i).append("<td id='realtion'>"+value["realtion"]+"</td>");
			$("#reportTable #row"+i).append("<td id='DOCUMENT_RTO_PASSING'></td>");
				
				var temp = $.parseJSON(value["DOCUMENT_RTO_PASSING"]);
				$.each(temp,function(key,value){
					if(value){
						$("#reportTable #row"+i+" #DOCUMENT_RTO_PASSING").append(key.replace("_"," ")+", ");
					}
					
				});
				
			$("#reportTable #row"+i).append("<td id='email_address'>"+value["email_address"]+"</td>");
			$("#reportTable #row"+i).append("<td id='booking_purchase_of_product'>"+value["booking_purchase_of_product"]+"</td>");
			$("#reportTable #row"+i).append("<td id='show_room_onPrice'>"+value["show_room_onPrice"]+"</td>");
			$("#reportTable #row"+i).append("<td id='ch_dd_no'>"+value["ch_dd_no"]+"</td>");
			$("#reportTable #row"+i).append("<td id='Mode_Of_Payment'></td>");
			
			var temp = $.parseJSON(value["Mode_Of_Payment"]);
			$.each(temp,function(key,value){
				console.log(key,'......',value);
				
				if(value){
					
					$("#reportTable #row"+i+" #Mode_Of_Payment").append(key+", ");
					
				}
				
			});
			
			
			$("#reportTable #row"+i).append("<td id='VbankName'>"+value["VbankName"]+"</td>");
			$("#reportTable #row"+i).append("<td id='amount'>"+value["amount"]+"</td>");
			$("#reportTable #row"+i).append("<td id='VahicalDate'>"+value["VahicalDate"]+"</td>");
			$("#reportTable #row"+i).append("<td id='fainance_by'>"+value["fainance_by"]+"</td>");
			$("#reportTable #row"+i).append("<td id='lone'>"+value["lone"]+"</td>");
			$("#reportTable #row"+i).append("<td id='dealers_showroom'>"+value["dealers_showroom"]+"</td>");
			$("#reportTable #row"+i).append("<td id='downpayment'>"+value["downpayment"]+"</td>");
			$("#reportTable #row"+i).append("<td id='inteaset'>"+value["inteaset"]+"</td>");
			$("#reportTable #row"+i).append("<td id='emi_amp_month'>"+value["emi_amp_month"]+"</td>");
			$("#reportTable #row"+i).append("<td id='date_of_emi'>"+value["date_of_emi"]+"</td>");
			$("#reportTable #row"+i).append("<td id='sahakar_a_l'>"+value["sahakar_a_l"]+"</td>");
			$("#reportTable #row"+i).append("<td id='sub_cidy'>"+value["sub_cidy"]+"</td>");
			$("#reportTable #row"+i).append("<td id='moto_vehicle_no'>"+value["moto_vehicle_no"]+"</td>");
			$("#reportTable #row"+i).append("<td id='engine_no'>"+value["engine_no"]+"</td>");
			$("#reportTable #row"+i).append("<td id='chassis_no'>"+value["chassis_no"]+"</td>");
			$("#reportTable #row"+i).append("<td id='color'>"+value["color"]+"</td>");
			$("#reportTable #row"+i).append("<td id='promotors_name'>"+value["promotors_name"]+"</td>");
			$("#reportTable #row"+i).append("<td id='id_no'>"+value["id_no"]+"</td>");
			$("#reportTable #row"+i).append("<td id='cell_no'>"+value["cell_no"]+"</td>");
			$("#reportTable #row"+i).append("<td id='FinalDate'>"+value["FinalDate"]+"</td>");
			
			$("#reportTable #row"+i+" td").addClass("tdTextEdit");
			
			
			i++;
		});
		
		console.log(rtoDocumentval,".....",saleryTypeVal,"......",modeOfPaymentval);
		$("#reportTable").show();
		$("#nodataFound").hide();
		fillToEportTableData(dataArr);
	}

function fillToEportTableData(dataArr){
	
	$("#exportReport").empty();
	$("#exportReport").append("<thead><tr><th>Sr No.</th><th>Application Name</th><th>Father/Husband Name</th><th>Date Of Birth</th><th>Gender</th>" +
			"<th>Marital Status</th><th>Current Job</th><th>Type Salary</th><th>Address</th><th>City</th><th>District</th><th>State</th>" +
			"<th>Pin Code</th><th>Phone No</th><th>Mobile No</th><th>Bank Name</th><th>Branch City</th><th>Account No</th><th>IFSC Code</th>" +
			"<th>C.I.No</th><th>Pan No</th><th>Nomine Name</th><th>Realtion</th><th>DOCUMENT RTO PASSING</th><th>Email Address</th><th>Booking Purchase Of Product</th>" +
			"<th>Show Room On Road Prise/Accessories</th><th>Chaque/DD No</th><th>Mode Of Payment</th><th>Bank</th><th>Amount</th>" +
			"<th>Date</th><th>Fainance By</th><th>Lone</th><th>Dealer/Showroom</th><th>Down Payment</th><th>Inteaset</th><th>EMI & Month</th>" +
			"<th>Date Of EMI</th><th>Sahakar A.I.LTD.D.P</th><th>Sub Cidy</th><th>Motor Vehicle No</th><th>Engin No</th><th>Chassis No</th>" +
			"<th>Color</th><th>Promotors Name</th><th>Id No</th><th>Cell No</th><th>Date</th></tr></thead>");
		

		rtoDocumentval = {}; 
		saleryTypeVal = {};
		modeOfPaymentval = {};
		var i = 1;
		$.each(dataArr,function(key,value){
			
			
			rtoDocumentval ["row"+i] = value["DOCUMENT_RTO_PASSING"]; 
			saleryTypeVal["row"+i] = value["Type_Salary"];
			modeOfPaymentval["row"+i] = value["Mode_Of_Payment"];
			
			 
			
			
			$("#exportReport").append("<tr id=row"+i+" name="+value["id"]+"></tr>");
			
			
			$("#exportReport #row"+i).append("<td align='left'>"+i+"</td>");
			$("#exportReport #row"+i).append("<td id='applicant_name'>"+value["applicant_name"]+"</td>");
			$("#exportReport #row"+i).append("<td id='father_husband_name'>"+value["father_husband_name"]+"</td>");
			$("#exportReport #row"+i).append("<td id='dateOfBirth'>"+value["dateOfBirth"]+"</td>");
			$("#exportReport #row"+i).append("<td id='sex'>"+value["sex"]+"</td>");
			$("#exportReport #row"+i).append("<td id='MaritalStatus'>"+value["MaritalStatus"]+"</td>");
			$("#exportReport #row"+i).append("<td id='CurrentJob'>"+value["CurrentJob"]+"</td>");
			$("#exportReport #row"+i).append("<td id='Type_Salary'></td>");
			
			var temp = $.parseJSON(value["Type_Salary"]);
			$.each(temp,function(key,value){
				if(value){
					$("#exportReport #row"+i+" #Type_Salary").append(key.replace("_"," ")+", ");
				}
				
			});
			
			
			$("#exportReport #row"+i).append("<td id='address'>"+value["address"]+"</td>");
			$("#exportReport #row"+i).append("<td id='City'>"+value["City"]+"</td>");
			$("#exportReport #row"+i).append("<td id='District'>"+value["District"]+"</td>");
			$("#exportReport #row"+i).append("<td id='State'>"+value["State"]+"</td>");
			$("#exportReport #row"+i).append("<td id='Pin_Code'>"+value["Pin_Code"]+"</td>");
			$("#exportReport #row"+i).append("<td id='Phone_No'>"+value["Phone_No"]+"</td>");
			$("#exportReport #row"+i).append("<td id='mobileNo'>"+value["mobileNo"]+"</td>");
			$("#exportReport #row"+i).append("<td id='bank_name'>"+value["bank_name"]+"</td>");
			$("#exportReport #row"+i).append("<td id='branch_city'>"+value["branch_city"]+"</td>");
			$("#exportReport #row"+i).append("<td id='account_no'>"+value["account_no"]+"</td>");
			$("#exportReport #row"+i).append("<td id='IFSC_code'>"+value["IFSC_code"]+"</td>");
			$("#exportReport #row"+i).append("<td id='c_i_no'>"+value["c_i_no"]+"</td>");
			$("#exportReport #row"+i).append("<td id='pan_no'>"+value["pan_no"]+"</td>");
			$("#exportReport #row"+i).append("<td id='nomine_name'>"+value["nomine_name"]+"</td>");
			$("#exportReport #row"+i).append("<td id='realtion'>"+value["realtion"]+"</td>");
			$("#exportReport #row"+i).append("<td id='DOCUMENT_RTO_PASSING'></td>");
				
				var temp = $.parseJSON(value["DOCUMENT_RTO_PASSING"]);
				$.each(temp,function(key,value){
					if(value){
						$("#exportReport #row"+i+" #DOCUMENT_RTO_PASSING").append(key.replace("_"," ")+", ");
					}
					
				});
				
			$("#exportReport #row"+i).append("<td id='email_address'>"+value["email_address"]+"</td>");
			$("#exportReport #row"+i).append("<td id='booking_purchase_of_product'>"+value["booking_purchase_of_product"]+"</td>");
			$("#exportReport #row"+i).append("<td id='show_room_onPrice'>"+value["show_room_onPrice"]+"</td>");
			$("#exportReport #row"+i).append("<td id='ch_dd_no'>"+value["ch_dd_no"]+"</td>");
			$("#exportReport #row"+i).append("<td id='Mode_Of_Payment'></td>");
			
			var temp = $.parseJSON(value["Mode_Of_Payment"]);
			$.each(temp,function(key,value){
				console.log(key,'......',value);
				
				if(value){
					
					$("#exportReport #row"+i+" #Mode_Of_Payment").append(key+", ");
					
				}
				
			});
			
			
			$("#exportReport #row"+i).append("<td id='VbankName'>"+value["VbankName"]+"</td>");
			$("#exportReport #row"+i).append("<td id='amount'>"+value["amount"]+"</td>");
			$("#exportReport #row"+i).append("<td id='VahicalDate'>"+value["VahicalDate"]+"</td>");
			$("#exportReport #row"+i).append("<td id='fainance_by'>"+value["fainance_by"]+"</td>");
			$("#exportReport #row"+i).append("<td id='lone'>"+value["lone"]+"</td>");
			$("#exportReport #row"+i).append("<td id='dealers_showroom'>"+value["dealers_showroom"]+"</td>");
			$("#exportReport #row"+i).append("<td id='downpayment'>"+value["downpayment"]+"</td>");
			$("#exportReport #row"+i).append("<td id='inteaset'>"+value["inteaset"]+"</td>");
			$("#exportReport #row"+i).append("<td id='emi_amp_month'>"+value["emi_amp_month"]+"</td>");
			$("#exportReport #row"+i).append("<td id='date_of_emi'>"+value["date_of_emi"]+"</td>");
			$("#exportReport #row"+i).append("<td id='sahakar_a_l'>"+value["sahakar_a_l"]+"</td>");
			$("#exportReport #row"+i).append("<td id='sub_cidy'>"+value["sub_cidy"]+"</td>");
			$("#exportReport #row"+i).append("<td id='moto_vehicle_no'>"+value["moto_vehicle_no"]+"</td>");
			$("#exportReport #row"+i).append("<td id='engine_no'>"+value["engine_no"]+"</td>");
			$("#exportReport #row"+i).append("<td id='chassis_no'>"+value["chassis_no"]+"</td>");
			$("#exportReport #row"+i).append("<td id='color'>"+value["color"]+"</td>");
			$("#exportReport #row"+i).append("<td id='promotors_name'>"+value["promotors_name"]+"</td>");
			$("#exportReport #row"+i).append("<td id='id_no'>"+value["id_no"]+"</td>");
			$("#exportReport #row"+i).append("<td id='cell_no'>"+value["cell_no"]+"</td>");
			$("#exportReport #row"+i).append("<td id='FinalDate'>"+value["FinalDate"]+"</td>");
			
			$("#exportReport #row"+i+" td").addClass("tdTextEdit");
			
			
			i++;
		});
		
		console.log(rtoDocumentval,".....",saleryTypeVal,"......",modeOfPaymentval);
		
		$("#nodataFound").hide();
}


